"""
@File    : base_dirver.py
@Author  : qve-wzy
@Time    : 2020/9/2 0002 10:13
"""
import time
from appium import webdriver
from util.wirteUserCommand import WriteUserCommand
class BaseDriver:
    '''
    获取driver
    '''
    def android_driver(self,i):
        print("--》this is android_driver:",i)
        #devices_name adb devices
        #port
        write_file = WriteUserCommand()
        devices = write_file.get_value('user_info_'+str(i),'deviceName')
        port = write_file.get_value('user_info_'+str(i),'port')

        capabilities = {
          "platformName": "Android",
          # "platforVersion": "7.1.2",
          "automationName":"UiAutomator2",
          "deviceName": devices,
          "app": "C:\\Program Files\\Appium1\\APPZX\\mukewang.apk",
          "appWaitActivity":"cn.com.open.mooc.index.splash.MCSplashActivity",
          # "appWaitActivity":"cn.com.open.mooc.user.login.MCLoginActivity",
          "noReset":"true",
          "appPackage":"cn.com.open.mooc"
          #"newCommandTimeout":'180'
        }
        driver = webdriver.Remote("http://127.0.0.1:"+port+"/wd/hub",capabilities)
        time.sleep(10)
        return driver

if __name__ == '__main__':
    ad =  BaseDriver()
    ad.android_driver(0)
    pass
